//
//  HomeDetailViewController.m
//  XRSquare
//
//  Created by UaenaMo on 2018/8/14.
//  Copyright © 2018年 UaenaMo. All rights reserved.
//

#import "HomeDetailViewController.h"
#import "DetailTopTableViewCell.h"
#import "DetailTitleTableViewCell.h"
#import "CompanyTableViewCell.h"
#import "DescriptionTableViewCell.h"
#import "RequestTableViewCell.h"
#import "SpecialTableViewCell.h"
#import "LocationTableViewCell.h"
#import "PhotoTableViewCell.h"
#import "OtherTableViewCell.h"
#import "MoreTableViewCell.h"
#import "ChatViewController.h"
#import "CompanyDetailViewController.h"
#import "PersonDetailViewController.h"
#import "FujinengTableViewCell.h"
#import "FileTableViewCell.h"
#import "BaoMingView.h"
#import "PGDatePickManager.h"
#import <UMShare/UMShare.h>

@interface HomeDetailViewController ()<UITableViewDataSource,UITableViewDelegate,BaoMingViewDelegate,PGDatePickerDelegate,PhotoTableViewCellDelegate,OtherDelegate,moreDelegate>
{
    UITableView * contentTableView;
    NSDictionary * contentData;
    UIButton * baoming;
    UIButton * sixin;
    NSString * file;
    NSString * other;
    BaoMingView * baomingv;
    UIBarButtonItem * collectItem;
}

@end

@implementation HomeDetailViewController

-(void)requestData
{
    [NetRequestCenter activitydetailwithtaskid:self.contentid result:^(BOOL success, NSDictionary *resultDic) {
        if (success) {
            contentData = [resultDic objectForKey:@"data"];
            [contentTableView reloadData];
            
            if ([[NSString stringWithFormat:@"%@",[contentData objectForKey:@"ItemUserEnrollStatus"]]isEqualToString:@"报名"])
            {
                [baoming setTitle:@"报名" forState:UIControlStateNormal];
                baoming.backgroundColor = themeColor;
            }
            else
            {
                [baoming setTitle:[contentData objectForKey:@"ItemUserEnrollStatus"] forState:UIControlStateNormal];
                baoming.enabled = NO;
                baoming.backgroundColor = [UIColor colorFromHexCode:@"b3b3b3"];
            }
            
            if ([[NSString stringWithFormat:@"%@",[contentData objectForKey:@"Type"]]isEqualToString:@"zhaopin"])
            {
                file = [NSString stringWithFormat:@"%@",[contentData objectForKey:@"ItemTaskFileName"]];
                other = [NSString stringWithFormat:@"%@",[contentData objectForKey:@"ItemTaskFiveTag"]];
            }
            
            if ([[contentData objectForKey:@"ItemTaskFavoriteStatus"]isEqualToString:@"收藏"])
            {
                UIBarButtonItem * shareItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"share-2"] style:UIBarButtonItemStylePlain target:self action:@selector(shareAction)];
                self->collectItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"collect"] style:UIBarButtonItemStylePlain target:self action:@selector(favAction)];
                self.navigationItem.rightBarButtonItems = @[self->collectItem,shareItem];
            }
            else
            {
                UIBarButtonItem * shareItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"share-2"] style:UIBarButtonItemStylePlain target:self action:@selector(shareAction)];
                self->collectItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"collected"] style:UIBarButtonItemStylePlain target:self action:@selector(favAction)];
                self.navigationItem.rightBarButtonItems = @[self->collectItem,shareItem];
            }
        }
        else
        {
            [SVProgressHUD showErrorWithStatus:[resultDic objectForKey:@"message"]];
            [self.navigationController popViewControllerAnimated:YES];
        }
    }];
}

-(void)backAction
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationController.navigationBarHidden = NO;
    self.navigationController.navigationBar.tintColor = [UIColor grayColor];
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"back"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] style:UIBarButtonItemStylePlain target:self action:@selector(backAction)];
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"发布"] style:UIBarButtonItemStylePlain target:self action:@selector(favAction)];
    
    CGRect rectStatus = [[UIApplication sharedApplication] statusBarFrame];
    CGRect rectNav = self.navigationController.navigationBar.frame;

    contentTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, rectStatus.size.height + rectNav.size.height, ScreenWidth, ScreenHeight - rectStatus.size.height - rectNav.size.height) style:UITableViewStylePlain];
    contentTableView.delegate = self;
    contentTableView.dataSource = self;
    contentTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.view addSubview:contentTableView];
    
    [self requestData];
    
    sixin = [[UIButton alloc]initWithFrame:CGRectMake(0, ScreenHeight - 50, ScreenWidth/2, 50)];
    sixin.backgroundColor = [UIColor whiteColor];
    sixin.titleLabel.font = [UIFont systemFontOfSize:15];
    [sixin setTitle:@"私信" forState:UIControlStateNormal];
    [sixin setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [sixin addTarget:self action:@selector(sixinAction) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:sixin];
    
    baoming = [[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth/2, ScreenHeight - 50, ScreenWidth/2, 50)];
    [baoming setTitleColor:[UIColor whiteColor] forState:UIControlStateDisabled];
    [baoming setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [baoming setTitle:@"报名" forState:UIControlStateNormal];
    baoming.titleLabel.font = [UIFont systemFontOfSize:15];
    baoming.backgroundColor = themeColor;
    [baoming addTarget:self action:@selector(baomingAction) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:baoming];
    
    UIView * line = [[UIView alloc]initWithFrame:CGRectMake(0, ScreenHeight - 50, ScreenWidth, 0.5)];
    line.backgroundColor = [UIColor colorFromHexCode:@"b3b3b3"];
    [self.view addSubview:line];
}

-(void)favAction
{
    if ([[contentData objectForKey:@"ItemTaskFavoriteStatus"]isEqualToString:@"收藏"])
    {
        [SVProgressHUD show];
        [NetRequestCenter favoriteactivityuid:self.contentid result:^(BOOL success, NSDictionary *resultDic) {
            if (success) {
                [SVProgressHUD showSuccessWithStatus:@"收藏成功"];
                [self requestData];
            }
            else
            {
                [SVProgressHUD showErrorWithStatus:[resultDic objectForKey:@"message"]];
            }
        }];
    }
    else
    {
        [SVProgressHUD show];
        [NetRequestCenter delfavoriteactivityuid:self.contentid result:^(BOOL success, NSDictionary *resultDic) {
            if (success) {
                [SVProgressHUD showSuccessWithStatus:@"取消收藏成功"];
                [self requestData];
            }
            else
            {
                [SVProgressHUD showErrorWithStatus:[resultDic objectForKey:@"message"]];
            }
        }];
    }
}

-(void)shareAction
{
    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil
                                                                             message:nil
                                                                      preferredStyle:UIAlertControllerStyleActionSheet];
    
    UIAlertAction * item1 = [UIAlertAction actionWithTitle:@"QQ" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
        [self qqAction];
    }];
    UIAlertAction * item2 = [UIAlertAction actionWithTitle:@"微信" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
        [self wechatFriendAction];
    }];
    
    UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
    }];
    
    [alertController addAction:item1];
    [alertController addAction:item2];
    [alertController addAction:cancelAction];
    
    [self presentViewController:alertController animated:YES completion:nil];
}

-(void)wechatFriendAction
{
    
    //创建分享消息对象
    UMSocialMessageObject *messageObject = [UMSocialMessageObject messageObject];
    //创建网页内容对象
    NSString * description = [contentData objectForKey:@"ItemTaskTitle"];
    NSString * imageUrl = [NSString stringWithFormat:@"%@",[contentData objectForKey:@"RightHeadPic"]];
    UMShareWebpageObject *shareObject = [UMShareWebpageObject shareObjectWithTitle:@"蓄锐广场" descr:description thumImage:imageUrl];
    //设置网页地址
    shareObject.webpageUrl = [NSString stringWithFormat:@"https://m.xrsquare.com/activitydetail?taskid=%@",self.contentid];
    //分享消息对象设置分享内容对象
    messageObject.shareObject = shareObject;
    //调用分享接口
    [[UMSocialManager defaultManager] shareToPlatform:UMSocialPlatformType_WechatSession messageObject:messageObject currentViewController:self completion:^(id data, NSError *error) {
        if (error) {
            UMSocialLogInfo(@"************Share fail with error %@*********",error);
        }else{
            if ([data isKindOfClass:[UMSocialShareResponse class]]) {
                UMSocialShareResponse *resp = data;
                //分享结果消息
                UMSocialLogInfo(@"response message is %@",resp.message);
                //第三方原始返回的数据
                UMSocialLogInfo(@"response originalResponse data is %@",resp.originalResponse);
            }else{
                UMSocialLogInfo(@"response data is %@",data);
            }
        }
    }];
}

-(void)qqAction
{
    
    //创建分享消息对象
    UMSocialMessageObject *messageObject = [UMSocialMessageObject messageObject];
    //创建网页内容对象
    NSString * description = [contentData objectForKey:@"ItemTaskTitle"];
    NSString * imageUrl = [NSString stringWithFormat:@"%@",[contentData objectForKey:@"RightHeadPic"]];
    UMShareWebpageObject *shareObject = [UMShareWebpageObject shareObjectWithTitle:@"蓄锐广场" descr:description thumImage:imageUrl];
    //设置网页地址
    shareObject.webpageUrl = [NSString stringWithFormat:@"https://m.xrsquare.com/activitydetail?taskid=%@",self.contentid];
    //分享消息对象设置分享内容对象
    messageObject.shareObject = shareObject;
    //调用分享接口
    [[UMSocialManager defaultManager] shareToPlatform:UMSocialPlatformType_QQ messageObject:messageObject currentViewController:self completion:^(id data, NSError *error) {
        if (error) {
            UMSocialLogInfo(@"************Share fail with error %@*********",error);
        }else{
            if ([data isKindOfClass:[UMSocialShareResponse class]]) {
                UMSocialShareResponse *resp = data;
                //分享结果消息
                UMSocialLogInfo(@"response message is %@",resp.message);
                //第三方原始返回的数据
                UMSocialLogInfo(@"response originalResponse data is %@",resp.originalResponse);
            }else{
                UMSocialLogInfo(@"response data is %@",data);
            }
        }
    }];
}


-(void)sixinAction
{
    ChatViewController * chat = [[ChatViewController alloc]init];
    chat.contentid = [contentData objectForKey:@"groupID"];
    chat.targetName = [contentData objectForKey:@"RightName"];
    chat.targetUid = [contentData objectForKey:@"RightUid"];
    chat.targetPic = [contentData objectForKey:@"RightHeadPic"];
    [self.navigationController pushViewController:chat animated:YES];
}

-(void)baomingAction
{
    baomingv = [[BaoMingView alloc]initWithFrame:CGRectZero];
    baomingv.delegate = self;
    baomingv.contentId = [contentData objectForKey:@"TaskID"];
    baomingv.week = [[contentData objectForKey:@"TaskWeekday"]componentsSeparatedByString:@"  "];
    [self.view addSubview:baomingv];
}

-(void)startTime
{
    PGDatePickManager *datePickManager = [[PGDatePickManager alloc]init];
    datePickManager.isShadeBackgroud = true;
    PGDatePicker *datePicker = datePickManager.datePicker;
    datePicker.delegate = self;
    datePicker.tag = 1;
    datePicker.datePickerType = PGPickerViewType2;
    datePicker.datePickerMode = PGDatePickerModeDateHourMinute;
    [self presentViewController:datePickManager animated:false completion:nil];
    
    [datePicker setDate:[NSDate date] animated:NO];
}

-(void)endTime
{
    PGDatePickManager *datePickManager = [[PGDatePickManager alloc]init];
    datePickManager.isShadeBackgroud = true;
    PGDatePicker *datePicker = datePickManager.datePicker;
    datePicker.delegate = self;
    datePicker.tag = 2;
    datePicker.datePickerType = PGPickerViewType2;
    datePicker.datePickerMode = PGDatePickerModeDateHourMinute;
    [self presentViewController:datePickManager animated:false completion:nil];
    
    [datePicker setDate:[NSDate date] animated:NO];
}

#pragma PGDatePickerDelegate
- (void)datePicker:(PGDatePicker *)datePicker didSelectDate:(NSDateComponents *)dateComponents {
    NSLog(@"dateComponents = %@", dateComponents);
    
    NSCalendar * calendar = [NSCalendar currentCalendar];
    NSDate * date = [calendar dateFromComponents:dateComponents];
    
    if (datePicker.tag == 1)
    {
        NSString * startTime = [NSString stringWithFormat:@"%ld-%02ld-%02ld %02ld:%02ld:%02ld",(long)dateComponents.year,(long)dateComponents.month,dateComponents.day,dateComponents.hour,dateComponents.minute,dateComponents.second];
        [baomingv selectStartTime:startTime];
    }
    if (datePicker.tag == 2)
    {
        NSString * endtime = [NSString stringWithFormat:@"%ld-%02ld-%02ld %02ld:%02ld:%02ld",(long)dateComponents.year,(long)dateComponents.month,dateComponents.day,dateComponents.hour,dateComponents.minute,dateComponents.second];
        [baomingv selectEndTime:endtime];
    }
}

#pragma mark - tableview

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 12;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0)
    {
        return [DetailTopTableViewCell height];
    }
    else if (indexPath.row == 1)
    {
        return [DetailTitleTableViewCell height];
    }
    else if (indexPath.row == 2)
    {
        return [CompanyTableViewCell height];
    }
    else if (indexPath.row == 3)
    {
        return [DescriptionTableViewCell heightWithData:[contentData objectForKey:@"ItemTaskDescription"]];
    }
    else if (indexPath.row == 4)
    {
        return [RequestTableViewCell heightWithData:[contentData objectForKey:@"ItemTaskDemand"]];
    }
    else if (indexPath.row == 5)
    {
        return [SpecialTableViewCell heightWithData:[contentData objectForKey:@"ItemNoCompanySpecialWelfare"]];
    }
    else if (indexPath.row == 6)
    {
        return [LocationTableViewCell heightWithData:[contentData objectForKey:@"ItemTaskAddress"]];
    }
    else if (indexPath.row == 7)
    {
        return [FujinengTableViewCell heightWithData:other];
    }
    else if (indexPath.row == 8)
    {
        return [FileTableViewCell heightWithData:file];
    }
    else if (indexPath.row == 9)
    {
        return [PhotoTableViewCell heightWithData:[contentData objectForKey:@"DomInsertPic"]];
    }
    else if (indexPath.row == 10)
    {
        return [OtherTableViewCell heightWithData:[contentData objectForKey:@"RightCompanyMoreActivity"]];
    }
    else
    {
        return [MoreTableViewCell heightWithData:[contentData objectForKey:@"RightCompanyMoreActivity"]];
    }
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0)
    {
        static NSString * identifer = @"DetailTopTableViewCell";
        DetailTopTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifer];
        if (!cell) {
            cell = [[DetailTopTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifer];
        }
        if ([[contentData allKeys]count])
        {
            [cell loadData:@{@"pic":[contentData objectForKey:@"ItemTaskPic"],@"num":[contentData objectForKey:@"ItemTaskPeopleNum"]}];
        }
        else
        {
            [cell loadData:nil];
        }
        return cell;
    }
    else if (indexPath.row == 1)
    {
        static NSString * identifer = @"DetailTitleTableViewCell";
        DetailTitleTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifer];
        if (!cell) {
            cell = [[DetailTitleTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifer];
        }
        
        if ([[contentData allKeys]count])
        {
            [cell loadtitle:[contentData objectForKey:@"ItemTaskTitle"] day:[contentData objectForKey:@"ItemTaskDeadTime"] type:[contentData objectForKey:@"ItemOnOffLine"] time:[NSString stringWithFormat:@"%@ %@",[contentData objectForKey:@"ItemTaskBeginTime"],[contentData objectForKey:@"ItemTaskEndTime"]]];
            
        }
        else
        {
            [cell loadtitle:nil day:nil type:nil time:nil];
        }
        return cell;
    }
    else if (indexPath.row == 2)
    {
        static NSString * identifer = @"CompanyTableViewCell";
        CompanyTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifer];
        if (!cell) {
            cell = [[CompanyTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifer];
        }
        if ([[contentData allKeys]count])
        {
            [cell loadimage:[contentData objectForKey:@"RightHeadPic"] title:[contentData objectForKey:@"RightName"] rate:[contentData objectForKey:@"RightHaoPing"] type:[contentData objectForKey:@"RightWeb_Company_HangYe"]];
        }
        else
        {
            [cell loadimage:nil title:nil rate:nil type:nil];
        }
        return cell;
    }
    else if (indexPath.row == 3)
    {
        static NSString * identifer = @"DescriptionTableViewCell";
        DescriptionTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifer];
        if (!cell) {
            cell = [[DescriptionTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifer];
        }
        if ([[contentData allKeys]count])
        {
            [cell loadData:[contentData objectForKey:@"ItemTaskDescription"]];
        }
        else
        {
            [cell loadData:nil];
        }
        
        return cell;
    }
    else if (indexPath.row == 4)
    {
        static NSString * identifer = @"RequestTableViewCell";
        RequestTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifer];
        if (!cell) {
            cell = [[RequestTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifer];
        }
        if ([[contentData allKeys]count])
        {
            [cell loadData:[contentData objectForKey:@"ItemTaskDemand"]];
        }
        else
        {
            [cell loadData:nil];
        }
        return cell;
    }
    else if (indexPath.row == 5)
    {
        static NSString * identifer = @"SpecialTableViewCell";
        SpecialTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifer];
        if (!cell) {
            cell = [[SpecialTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifer];
        }
        if ([[contentData allKeys]count])
        {
            [cell loadData:[contentData objectForKey:@"ItemNoCompanySpecialWelfare"]];
        }
        else
        {
            [cell loadData:nil];
        }
        return cell;
    }
    else if (indexPath.row == 6)
    {
        static NSString * identifer = @"LocationTableViewCell";
        LocationTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifer];
        if (!cell) {
            cell = [[LocationTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifer];
        }
        if ([[contentData allKeys]count])
        {
            [cell loadData:[contentData objectForKey:@"ItemTaskAddress"]];
        }
        else
        {
            [cell loadData:nil];
        }
        return cell;
    }
    else if (indexPath.row == 7)
    {
        static NSString * identifer = @"FujinengTableViewCell";
        FujinengTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifer];
        if (!cell) {
            cell = [[FujinengTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifer];
        }
        if ([[contentData allKeys]count])
        {
            [cell loadData:other];
        }
        else
        {
            [cell loadData:nil];
        }
        return cell;
    }
    else if (indexPath.row == 8)
    {
        static NSString * identifer = @"FileTableViewCell";
        FileTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifer];
        if (!cell) {
            cell = [[FileTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifer];
        }
        if ([[contentData allKeys]count])
        {
            [cell loadData:file];
        }
        else
        {
            [cell loadData:nil];
        }
        return cell;
    }
    else if (indexPath.row == 9)
    {
        static NSString * identifer = @"PhotoTableViewCell";
        PhotoTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifer];
        if (!cell) {
            cell = [[PhotoTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifer];
        }
        cell.delegate = self;
        if ([[contentData allKeys]count])
        {
            [cell loadData:[contentData objectForKey:@"DomInsertPic"]];
        }
        else
        {
            [cell loadData:nil];
        }

        return cell;
    }
    else if (indexPath.row == 10)
    {
        static NSString * identifer = @"OtherTableViewCell";
        OtherTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifer];
        if (!cell) {
            cell = [[OtherTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifer];
        }
        cell.delegate = self;
        [cell loadData:[contentData objectForKey:@"RightCompanyMoreActivity"]];
        return cell;
    }
    else
    {
        static NSString * identifer = @"MoreTableViewCell";
        MoreTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifer];
        if (!cell) {
            cell = [[MoreTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifer];
        }
        cell.delegate = self;
        [cell loadData:[contentData objectForKey:@"RightSimilarActivity"]];
        return cell;
    }
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if (indexPath.row == 2)
    {
        if ([[NSString stringWithFormat:@"%@",[contentData objectForKey:@"ZhuBanFangType"]]isEqualToString:@"0"])
        {
            PersonDetailViewController * person = [[PersonDetailViewController alloc]init];
            person.uid = [contentData objectForKey:@"RightUid"];
            [self.navigationController pushViewController:person animated:YES];
        }
        else
        {
            CompanyDetailViewController* person = [[CompanyDetailViewController alloc]init];
            person.contentId = [contentData objectForKey:@"RightUid"];
            [self.navigationController pushViewController:person animated:YES];
        }
    }
    if (indexPath.row == 8) {
        WebViewController * webView = [[WebViewController alloc]init];
        webView.url = [NSString stringWithFormat:@"https://pic.xrsquare.com/%@",[contentData objectForKey:@"ItemTaskFile"]];
        [self.navigationController pushViewController:webView animated:YES];
    }
}

-(void)selectedContent:(NSDictionary *)contennt
{
    HomeDetailViewController * home = [[HomeDetailViewController alloc]init];
    home.contentid = [contennt objectForKey:@"TaskID"];
    [self.navigationController pushViewController:home animated:YES];
}

-(void)selectedImage:(NSInteger )index images:(NSArray * )images;
{
    MYPhotoBrowser *photoBrowser = [[MYPhotoBrowser alloc]initWithUrls:images imgViews:nil placeholder:nil currentIdx:index handleNames:nil callback:^(UIImage *handleImage,NSString *handleType) {
        
        NSLog(@"-------------图片对象-%@----操作类型-%ld",handleImage,(long)handleType);
        
    }];
    [photoBrowser showWithAnimation:YES];

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
